using UnityEngine;
using System.Collections;

public class InitMain : MonoBehaviour
{
	void Awake ()
	{
		ModelLocator.getInstance ().dispacthEvent (CustomToClientFlag.SERVER_CUSTOMMSG_ADD_MAINROLE, 
		new object[]{PlayerData.Instance().initDataArray});
		
		
		/*
		//Init of display layer
		#region
		if(GameDefine.FIRSTINITMAIN == true){
			if (prefabPath == "")
				return;
			
			filePath = "Prefabs/" + prefabPath;
			GameObject go = (GameObject)Instantiate (Resources.Load (filePath));
			go.transform.parent = camera.transform;
			go.transform.localPosition = new Vector3 (-300, -210, 0);
			go.transform.localScale = Vector3.one;
			go.name = "MainPlayer";
			go.tag = "SceneObject";
			
			PlayerData.Instance().MainRoleInstance = go;
			
			PlayerAction pa = go.GetComponent<PlayerAction> ();
			pa.speed = playerSpeed;
			
			
			
			/*
			GameObject taskWindow = (GameObject)Instantiate (Resources.Load ("UI/Window_AccessTask"));
			taskWindow.transform.parent = camera.transform;
			taskWindow.transform.localPosition = Vector3.zero;
			taskWindow.transform.localScale = Vector3.one;
			pa.taskInterface = taskWindow;
			taskWindow.SetActive (false);
			
			MouseReplace mr = camera.GetComponent<MouseReplace> ();
			mr.playerAction = pa;
			*/
		
		
		
		//Encounter
		/*
		if (SceneManagement.GetInstance ().nextScene == "Encounter") {
			if (TaskStatus.Instance ().fightScene == -1)
				TaskStatus.Instance ().fightScene = 0;
			
			GameObject bear1 = GameObject.Find ("Monster1");
			GameObject bear2 = GameObject.Find ("Monster2");
			if (TaskStatus.Instance ().fightScene == 1) {
				camera.transform.position = sf.rightPoint.position - Vector3.right;
				go.transform.localPosition = new Vector3 (0, -210, 0);
				if (bear2) {
					SceneFightNpc sfn = bear2.GetComponent<SceneFightNpc> ();
					sfn.mainRole = go;
				}
				
				if(bear1){
					bear1.SetActive(false);
				}
			} else if(TaskStatus.Instance ().fightScene == 0){
				if (bear1) {
					SceneFightNpc sfn = bear1.GetComponent<SceneFightNpc> ();
					sfn.mainRole = go;
				}
			}
		} else {
			//Init camera's position
			if (TaskStatus.Instance ().fightScene != -1) {
				camera.transform.position = sf.rightPoint.position;
				go.transform.localPosition = new Vector3 (0, -210, 0);
			}
		}
		
			//TODO
			string sex = "";
			string profession = "";
			ClipAnimation clipAnimation = go.GetComponentInChildren<ClipAnimation> ();
			switch (CreateRoleInfo.GetInstance().Sex) {
			case ConstData.FEMALE:
				sex = "nv";
				break;
			case ConstData.MALE:
				sex = "nan";
				break;
			default :
				break;
			}
				
			switch (CreateRoleInfo.GetInstance().Profession) {
			case (int)GameDefine.Profession.MENGJIANG:
				profession = "mengjiang";
				break;
			case (int)GameDefine.Profession.SHENSHE:
				profession = "shenshe";
				break;
			case (int)GameDefine.Profession.MOUSHI:
				profession = "moushi";
				break;
			default :
				break;
			}
			clipAnimation.filePath = profession + "_" + sex;
			
			clipAnimation.Play ("idle");
			
			//At the end of init,set the flag false;
			GameDefine.FIRSTINITMAIN = false;
		}
		#endregion
		
		//Init of data layer
	*/
	}
}
